/*
 * @Author: your name
 * @Date: 2021-10-21 11:50:16
 * @LastEditTime: 2022-09-28 11:02:24
 * @LastEditors: lbt666 '1319451895@qq.com'
 * @Description: 数据计算方法
 */
import Big from 'big.js';


/**
 * 方法说明
 * Big.PE = 50
 * @param number : integer, 0 to 1e+6 inclusive
 * Default value: 21
 * The positive exponent value at and above which toString returns exponential notation.
 * 文档地址https://mikemcl.github.io/big.js/legacy/v5.2.x.html#big
 */
Big.PE = 50
Big.DP = 20
// const Big1 = require('bignumber.js')

function parseNumber (number, power) {
  return roundFun(new Big(String(number)).div(new Big(10).pow(power)).toNumber(), 4)
}
// 乘法
function pow (number, power) {
  return new Big(number).times(new Big(10).pow(power)).toString()
}
// 按精度舍入，参数表示小数点后位数
function roundFun (value, n) {
  return Math.round(value * Math.pow(10, n)) / Math.pow(10, n)
}
// 除法(除数，指数)
function chufa (value, n) {
  return new Big(value).div(new Big(Math.pow(10, n)))
}
function jianfa (val1, val2) {
  return new Big(val1).minus(val2)
}
function jiafa (val1, val2) {
  return new Big(val1).plus(val2)
}

export {
  parseNumber,
  pow,
  roundFun,
  chufa,
  jianfa,
  jiafa
}
